package com.andy.nature.ui.activity

import android.graphics.drawable.Drawable
import com.andy.common.base.BaseVMActivity
import com.andy.common.extend.setOnIMClickListener
import com.andy.nature.databinding.ActivityBlurBinding
import com.andy.nature.ui.adapter.MessageAdapter
import com.andy.nature.vm.CommonViewModel
import jp.wasabeef.blurry.Blurry

/**
 * Author:Andy
 * Date:2023/4/27 17:51
 * Description:AnimationActivity
 */
class BlurActivity : BaseVMActivity<ActivityBlurBinding, CommonViewModel>() {
    var originBackground: Drawable? = null
    private val messageAdapter: MessageAdapter by lazy {
        MessageAdapter()
    }

    override fun viewModelClass(): Class<CommonViewModel> {
        return CommonViewModel::class.java
    }

    override fun getViewBinding(): ActivityBlurBinding {
        return ActivityBlurBinding.inflate(layoutInflater)
    }

    override fun initObserve() {
        mViewModel.testLiveData.observe(this) {
            messageAdapter.setData(it)
        }
    }

    override fun initData() {
        mBinding?.apply {
        }
    }

    override fun initAction() {
        mBinding?.apply {
            vTitle.setClickLeftCallBack {
                finish()
            }
            btnOrigin.setOnIMClickListener {
                Blurry.delete(root)
            }
            btnBlur.setOnIMClickListener {
                originBackground = root.background
                Blurry.with(this@BlurActivity)
                    .radius(20)
                    .sampling(2)
                    .async()
                    .animate(200)
                    .onto(root)
            }
        }
    }

}